Crate geo

source ·
Expand description

The geo crate provides geospatial primitive types and algorithms.

§Types

The preceding types are reexported from the geo-types crate. Consider using that crate if you only need access to these types and no other geo functionality.

§Semantics

The geospatial types provided here aim to adhere to the OpenGIS Simple feature access standards. Thus, the types here are inter-operable with other implementations of the standards: JTS, GEOS, etc.

§Algorithms

§Area

  • Area: Calculate the planar area of a geometry
  • ChamberlainDuquetteArea: Calculate the geodesic area of a geometry on a sphere using the algorithm presented in Some Algorithms for Polygons on a Sphere by Chamberlain and Duquette (2007)
  • GeodesicArea: Calculate the geodesic area and perimeter of a geometry on an ellipsoid using the algorithm presented in Algorithms for geodesics by Charles Karney (2013)

§Boolean Operations

  • BooleanOps: combine or split (Multi)Polygons using intersecton, union, xor, or difference operations

§Distance

  • EuclideanDistance: Calculate the minimum euclidean distance between geometries
  • GeodesicDistance: Calculate the minimum geodesic distance between geometries using the algorithm presented in Algorithms for geodesics by Charles Karney (2013)
  • HausdorffDistance: Calculate “the maximum of the distances from a point in any of the sets to the nearest point in the other set.” (Rote, 1991)
  • HaversineDistance: Calculate the minimum geodesic distance between geometries using the haversine formula
  • RhumbDistance: Calculate the length of a rhumb line connecting the two geometries
  • VincentyDistance: Calculate the minimum geodesic distance between geometries using Vincenty’s formula

§Length

  • EuclideanLength: Calculate the euclidean length of a geometry
  • GeodesicLength: Calculate the geodesic length of a geometry using the algorithm presented in Algorithms for geodesics by Charles Karney (2013)
  • HaversineLength: Calculate the geodesic length of a geometry using the haversine formula
  • RhumbLength: Calculate the length of a geometry assuming it’s composed of rhumb lines
  • VincentyLength: Calculate the geodesic length of a geometry using Vincenty’s formula

§Outlier Detection

§Simplification

  • Simplify: Simplify a geometry using the Ramer–Douglas–Peucker algorithm
  • SimplifyIdx: Calculate a simplified geometry using the Ramer–Douglas–Peucker algorithm, returning coordinate indices
  • SimplifyVw: Simplify a geometry using the Visvalingam-Whyatt algorithm
  • SimplifyVwPreserve: Simplify a geometry using a topology-preserving variant of the Visvalingam-Whyatt algorithm
  • SimplifyVwIdx: Calculate a simplified geometry using the Visvalingam-Whyatt algorithm, returning coordinate indices

§Query

  • HaversineBearing: Calculate the bearing between points using great circle calculations.
  • GeodesicBearing: Calculate the bearing between points on a geodesic
  • RhumbBearing: Calculate the angle from north of the rhumb line connecting two points.
  • ClosestPoint: Find the point on a geometry closest to a given point
  • HaversineClosestPoint: Find the point on a geometry closest to a given point on a sphere using spherical coordinates and lines being great arcs.
  • IsConvex: Calculate the convexity of a LineString
  • LineInterpolatePoint: Generates a point that lies a given fraction along the line
  • LineLocatePoint: Calculate the fraction of a line’s total length representing the location of the closest point on the line to the given point

§Similarity

§Topology

  • Contains: Calculate if a geometry contains another geometry
  • CoordinatePosition: Calculate the position of a coordinate relative to a geometry
  • HasDimensions: Determine the dimensions of a geometry
  • Intersects: Calculate if a geometry intersects another geometry
  • line_intersection: Calculates the intersection, if any, between two lines.
  • Relate: Topologically relate two geometries based on DE-9IM semantics.
  • Within: Calculate if a geometry lies completely within another geometry.

§Triangulation

  • TriangulateEarcut: Triangulate polygons using the earcut algorithm (requires the earcutr feature).

§Winding

§Iteration

  • CoordsIter: Iterate over the coordinates of a geometry
  • MapCoords: Map a function over all the coordinates in a geometry, returning a new geometry
  • MapCoordsInPlace: Map a function over all the coordinates in a geometry in-place
  • LinesIter: Iterate over lines of a geometry

§Boundary

  • BoundingRect: Calculate the axis-aligned bounding rectangle of a geometry
  • MinimumRotatedRect: Calculate the minimum bounding box of a geometry
  • ConcaveHull: Calculate the concave hull of a geometry
  • ConvexHull: Calculate the convex hull of a geometry
  • Extremes: Calculate the extreme coordinates and indices of a geometry

§Affine transformations

  • Rotate: Rotate a geometry around its centroid
  • Scale: Scale a geometry up or down by a factor
  • Skew: Skew a geometry by shearing angles along the x and y dimension
  • Translate: Translate a geometry along its axis
  • AffineOps: generalised composable affine operations

§Conversion

  • Convert: Convert (infalliby) the type of a geometry’s coordinate value
  • TryConvert: Convert (falliby) the type of a geometry’s coordinate value
  • ToDegrees: Radians to degrees coordinate transforms for a given geometry.
  • ToRadians: Degrees to radians coordinate transforms for a given geometry.

§Miscellaneous

  • Centroid: Calculate the centroid of a geometry
  • ChaikinSmoothing: Smoothen LineString, Polygon, MultiLineString and MultiPolygon using Chaikin’s algorithm.
  • Densify: Densify linear geometry components by interpolating points
  • DensifyHaversine: Densify spherical geometry by interpolating points on a sphere
  • GeodesicDestination: Given a start point, bearing, and distance, calculate the destination point on a geodesic
  • GeodesicIntermediate: Calculate intermediate points on a geodesic
  • HaversineDestination: Given a start point, bearing, and distance, calculate the destination point on a sphere assuming travel on a great circle
  • HaversineIntermediate: Calculate intermediate points on a sphere along a great-circle line
  • RhumbDestination: Given a start point, bearing, and distance, calculate the destination point on a sphere assuming travel along a rhumb line
  • RhumbIntermediate: Calculate intermediate points on a sphere along a rhumb line
  • [proj]: Project geometries with the proj crate (requires the use-proj feature)
  • LineStringSegmentize: Segment a LineString into n segments.
  • LineStringSegmentizeHaversine: Segment a LineString using Haversine distance.
  • [Transform]: Transform a geometry using Proj.
  • RemoveRepeatedPoints: Remove repeated points from a geometry.

§Features

The following optional Cargo features are available:

  • proj-network: Enables network grid support for the proj crate. After enabling this feature, further configuration is required to use the network grid
  • use-proj: Enables coordinate conversion and transformation of Point geometries using the proj crate
  • use-serde: Allows geometry types to be serialized and deserialized with Serde

§Ecosystem

There’s a wide variety of geo-compatible crates in the ecosystem that offer functionality not included in the geo crate, including:

Re-exports§

Modules§

  • This module includes all the functions of geometric calculations
  • This module makes all geometry types available
  • A prelude which re-exports the traits for manipulating objects in this crate. Typically imported with use geo::prelude::*.

Macros§

Enums§

  • The result of trying to find the closest spot on an object to a point.

Traits§

  • For algorithms which can only use floating point Points/Coords, like area or length calculations
  • For algorithms which can use both integer and floating point Points/Coords
  • A common numeric trait used for geo algorithms
  • A trait for methods which work for both integers and floating point